package top.fengyulou.config;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import top.fengyulou.config.interceptor.LoginInterceptor;
import top.fengyulou.config.interceptor.ProjectInterceptor;
import top.fengyulou.config.interceptor.CommonInterceptor;

import javax.annotation.Resource;

@Configuration
@EnableConfigurationProperties(SysConfig.class)
public class WebConfig implements WebMvcConfigurer {

    @Resource
    private LoginInterceptor loginInterceptor;
    @Resource
    private CommonInterceptor commonInterceptor;
    @Resource
    private ProjectInterceptor projectInterceptor;
    @Resource
    private SysConfig sysConfig;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //登录拦截
        registry.addInterceptor(loginInterceptor).addPathPatterns("/b/**");
        //公共拦截
        registry.addInterceptor(commonInterceptor).addPathPatterns("/", "/f/**", "/b/**");
    }
}